<?php
/***************************************************************
*  Copyright notice
*  (c) 2009, jianyuzhu@gmail.com
*  All rights reserved
*  This script is part of the PPEMI project.
***************************************************************/

class CoreGenerateTableBase extends Base {
	
	//constructor
	function CoreGenerateTableBase() {
		parent::Base();
	}
	
	//methods
	function createItemClassDB($dbname) {
		$prefix = 'ci_';
		$sql = "
CREATE TABLE `" . $dbname . "` (
  `" . $prefix . "id` int(11) unsigned NOT NULL auto_increment,
  `" . $prefix . "owner` int(11) NOT NULL default '0',
  `" . $prefix . "type` tinyint(1) NOT NULL default '0',
  `" . $prefix . "subject` varchar(200) NOT NULL default '',
  `" . $prefix . "content` text NOT NULL,
  `" . $prefix . "start_time` int(10) unsigned NOT NULL default '0',
  `" . $prefix . "end_time` int(10) unsigned NOT NULL default '0',
  `" . $prefix . "date_added` datetime NOT NULL default '0000-00-00 00:00:00',
  `" . $prefix . "added_by` int(11) NOT NULL default '0',
  `" . $prefix . "last_modified` datetime NOT NULL default '0000-00-00 00:00:00',
  `" . $prefix . "modified_by` int(11) NOT NULL default '0',
  `" . $prefix . "sort_order` int(11) NOT NULL default '0',
  `" . $prefix . "status` tinyint(4) NOT NULL default '0',
  PRIMARY KEY  (`" . $prefix . "id`),
  KEY `timespan` (`" . $prefix . "start_time`,`" . $prefix . "end_time`)
) TYPE=MyISAM AUTO_INCREMENT=1";
		
		$this->adb->query($sql);
	}
	
	function createItemCategoryClassDB($dbname) {
		$prefix = 'ci_';
		$sql = "
CREATE TABLE `" . $dbname . "` (
  `" . $prefix . "id` int(11) unsigned NOT NULL auto_increment,
  `" . $prefix . "owner` int(11) NOT NULL default '0',
  `categories_id` int(11) NOT NULL default '0',
  `" . $prefix . "type` tinyint(1) NOT NULL default '0',
  `" . $prefix . "subject` varchar(200) NOT NULL default '',
  `" . $prefix . "content` text NOT NULL,
  `" . $prefix . "start_time` int(10) unsigned NOT NULL default '0',
  `" . $prefix . "end_time` int(10) unsigned NOT NULL default '0',
  `" . $prefix . "date_added` datetime NOT NULL default '0000-00-00 00:00:00',
  `" . $prefix . "added_by` int(11) NOT NULL default '0',
  `" . $prefix . "last_modified` datetime NOT NULL default '0000-00-00 00:00:00',
  `" . $prefix . "modified_by` int(11) NOT NULL default '0',
  `" . $prefix . "sort_order` int(11) NOT NULL default '0',
  `" . $prefix . "status` tinyint(4) NOT NULL default '0',
  PRIMARY KEY  (`" . $prefix . "id`),
  KEY `timespan` (`" . $prefix . "start_time`,`" . $prefix . "end_time`)
) TYPE=MyISAM AUTO_INCREMENT=1";
		
		$this->adb->query($sql);
	}
	
	function createCategoryClassDB($dbname) {
		$sql = "
CREATE TABLE `" . $dbname . "` (
  `categories_id` int(11) NOT NULL auto_increment,
  `categories_parent` int(11) NOT NULL default '0',
  `categories_owner` int(11) NOT NULL default '0',
  `categories_type` varchar(10) NOT NULL default '',
  `categories_link` varchar(100) NOT NULL default '',
  `categories_name` varchar(200) NOT NULL default '',
  `categories_description` text NOT NULL,
  `categories_image` varchar(100) NOT NULL default '',
  `categories_images` tinytext NOT NULL,
  `categories_date_added` datetime NOT NULL default '0000-00-00 00:00:00',
  `categories_added_by` int(11) NOT NULL default '0',
  `categories_last_modified` datetime NOT NULL default '0000-00-00 00:00:00',
  `categories_modified_by` int(11) NOT NULL default '0',
  `categories_sort_order` int(11) NOT NULL default '0',
  `categories_status` tinyint(4) NOT NULL default '0',
  PRIMARY KEY  (`categories_id`)
) TYPE=MyISAM AUTO_INCREMENT=1";
		
		$this->adb->query($sql);
	}
}
//
?>